#include ".\print_string.h"
#include "..\..\bsp\uart\uart.h"

WEAK bool out_char(uint8_t chByte)
{
    return false;
}
def_simple_fsm(print_string,
    def_params(
        uint8_t *pchString;
    ))

fsm_initialiser(print_string,
    args(
        uint8_t *pchString
    ))
    init_body(
        this.pchString = pchString;
    )

fsm_implementation(print_string)
{
    def_states(
        CHECK_ZERO,
        PRINT_CHAR
    )
    
    body_begin();
    
        state(CHECK_ZERO) {
            if (0 == *this.pchString) {
                fsm_cpl();
            } else {
                update_state_to(PRINT_CHAR)
            }
        }
        
        state(PRINT_CHAR) {
            if (out_char(*this.pchString)) {
                this.pchString += 1;
                transfer_to(CHECK_ZERO);
            }
        }
    
    body_end();
}